package clientDemo.service.impl;

import clientDemo.entity.RuntimeParameter;
import clientDemo.httpUtil.HttpMethod;
import clientDemo.httpUtil.HttpRequest;
import clientDemo.httpUtil.HttpResponse;
import clientDemo.service.RuntimeParameterService;
import com.alibaba.fastjson.JSON;

public class RuntimeParameterServiceImpl implements RuntimeParameterService{
    @Override
    public RuntimeParameter put(RuntimeParameter runtimeParameter) {
        HttpRequest request = new HttpRequest();
        request.method(HttpMethod.PUT)
                .host("127.0.0.1")
                .port(8080)
                .path("/api/v2/runtimeParameters/"+runtimeParameter.getId())
                .contentType("application/json")
                .data(JSON.toJSONString(runtimeParameter));
        HttpResponse response = request.send();
        int status=response.statusCode();
		if (status == 200) {
			 return JSON.parseObject(response.body(), RuntimeParameter.class);
		}
		return null;
       
    }
}
